/*
 * @Date: 2022-05-16 16:55:59
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-05-16 17:01:05
 * @FilePath: \react-lvyou\src\components\privateCmp\index.tsx
 * @Description: 登录路由守卫
 */
import { useSelector } from "@/store/hooks";
import React, { memo } from "react";
import { Navigate } from "react-router-dom";
const PrivateComponent = (props: { children: React.ReactNode }) => {
  const { token } = useSelector((state) => ({
    token: state.User.token,
  }));
  return token !== null ? (
    <>{props.children}</>
  ) : (
    <Navigate to="/login" replace></Navigate>
  );
};
export default PrivateComponent;
